home *** CD-ROM | disk | FTP | other *** search
- page ,132
- ;----------------------------Module-Header------------------------------;
- ; Module Name: SETDI8.ASM
- ;
- ; move bits from one DIB format into another. doing color conversion if
- ; needed.
- ;
- ; convert_8_8
- ; convert_16_8
- ; convert_24_8
- ; convert_32_8
- ; copy_8_8
- ; dither_8_8
- ;
- ; NOTES:
- ;
- ; dither needs to work!
- ;
- ; AUTHOR: ToddLa (Todd Laney) Microsoft
- ;
- ;-----------------------------------------------------------------------;
- ?PLM=1
- ?WIN=0
- .xlist
- include cmacro32.inc
- include windows.inc
- .list
-
- sBegin Data
- sEnd Data
-
- ifndef SEGNAME
- SEGNAME equ <_TEXT32>
- endif
-
- createSeg %SEGNAME, CodeSeg, word, public, CODE
-
- sBegin CodeSeg
- .386
- assumes cs,CodeSeg
- assumes ds,nothing
- assumes es,nothing
-
- ;--------------------------------------------------------------------------;
- ;--------------------------------------------------------------------------;
-
- nxtscan macro reg, next_scan, fill_bytes
- ifb <fill_bytes>
- add e®,next_scan
- else
- mov eax,e®
- add e®,next_scan
- cmp ax,reg
- sbb eax,eax
- and eax,fill_bytes
- add e®,eax
- endif
- endm
-
- NEWCODE equ 1
-
- if NEWCODE
-
- ;--------------------------------------------------------------------------;
- ;
- ; convert_8_8
- ;
- ;--------------------------------------------------------------------------;
- assumes ds,nothing
- assumes es,nothing
-
- cProc convert_8_8,<FAR,PUBLIC,PASCAL>,<esi,edi,ds>
- ParmD dst_ptr ; --> dst.
- ParmD dst_offset ; offset to start at. > 64k
- ParmD dst_next_scan ; dst_next_scan. < 64k signed
- ParmD src_ptr ; --> src.
- ParmD src_offset ; offset to start at > 64k
- ParmD src_next_scan ; dst_next_scan. < 64k signed
- ParmD pel_count ; pixel count. < 64k unsigned
- ParmD scan_count ; scan count. < 64k unsigned
- ParmD xlat_table ; pixel convert table. ds:0
- cBegin
- xor esi,esi
- xor edi,edi
- xor ebx,ebx
- xor edx,edx
- lfs si,src_ptr
- les di,dst_ptr
- lds bx,xlat_table
-
- add esi,src_offset
- add edi,dst_offset
-
- mov eax,pel_count
- sub src_next_scan,eax
- sub dst_next_scan,eax
-
- xor ebx,ebx
- align 4
- convert_8_8_start:
-
- mov ecx,pel_count
- shr ecx,2
- jz short convert_8_8_ack
-
- shr ecx,1
- jc fixup_for_halfway
-
- align 4
- convert_8_8_loop:
-
- mov eax,fs:[esi] ; grab 4 pixels
-
- mov bl,al ; get pel
- mov dl,ah ; get pel
- mov al,[ebx] ; translate pel
- mov ah,[edx] ; translate pel
-
- rol eax,16
-
- mov bl,al ; get pel
- mov dl,ah ; get pel
- mov al,[ebx] ; translate pel
- mov ah,[edx] ; translate pel
-
- rol eax,16
-
- mov es:[edi],eax ; store four
-
- half_way:
- mov eax,fs:[esi+4] ; grab 4 pixels
-
- mov bl,al ; get pel
- mov dl,ah ; get pel
- mov al,[ebx] ; translate pel
- mov ah,[edx] ; translate pel
-
- rol eax,16
-
- mov bl,al ; get pel
- mov dl,ah ; get pel
- mov al,[ebx] ; translate pel
- mov ah,[edx] ; translate pel
-
- rol eax,16
-
- mov es:[edi+4],eax ; store four
-
- add esi,8
- add edi,8
-
- dec ecx
- jnz short convert_8_8_loop
-
- convert_8_8_ack:
- mov ecx,pel_count
- and ecx,3
- jnz short convert_8_8_odd
-
- convert_8_8_next:
- nxtscan si,src_next_scan
- nxtscan di,dst_next_scan
-
- dec scan_count
- jnz short convert_8_8_start
- cEnd
-
- fixup_for_halfway:
- sub edi,4
- sub esi,4
- jmp half_way
-
- convert_8_8_odd:
- @@: mov bl,fs:[esi]
- mov bl,[ebx]
- mov es:[edi],bl
- inc esi
- inc edi
- dec ecx
- jnz short convert_8_8_odd
- jz short convert_8_8_next
-
- else
- ;--------------------------------------------------------------------------;
- ;
- ; convert_8_8
- ;
- ;--------------------------------------------------------------------------;
- assumes ds,nothing
- assumes es,nothing
-
- cProc convert_8_8,<FAR,PUBLIC,PASCAL>,<esi,edi,ds>
- ParmD dst_ptr ; --> dst.
- ParmD dst_offset ; offset to start at
- ParmD dst_next_scan ; dst_next_scan.
- ParmD src_ptr ; --> src.
- ParmD src_offset ; offset to start at
- ParmD src_next_scan ; dst_next_scan.
- ParmD pel_count ; pixel count.
- ParmD scan_count ; scan count.
- ParmD xlat_table ; pixel convert table.
- cBegin
- xor esi,esi
- xor edi,edi
- xor ebx,ebx
- lfs si,src_ptr
- les di,dst_ptr
- lds bx,xlat_table
-
- add esi,src_offset
- add edi,dst_offset
-
- mov eax,pel_count
- sub src_next_scan,eax
- sub dst_next_scan,eax
-
- mov edx,pel_count
- xor ebx,ebx
- align 4
- convert_8_8_start:
- mov ecx,edx ;pel_count
- shr ecx,2
- jz short convert_8_8_ack
- align 4
- convert_8_8_loop:
- mov eax,fs:[esi] ; grab 4 pixels
-
- mov bl,al ; get pel
- mov al,[ebx] ; translate pel
- mov bl,ah ; get pel
- mov ah,[ebx] ; translate pel
-
- rol eax,16
-
- mov bl,al ; get pel
- mov al,[ebx] ; translate pel
- mov bl,ah ; get pel
- mov ah,[ebx] ; translate pel
-
- rol eax,16
- mov es:[edi],eax ; store four
-
- add esi,4
- add edi,4
- dec ecx
- jnz short convert_8_8_loop
-
- convert_8_8_ack:
- mov ecx,edx ;pel_count
- and ecx,3
- jnz short convert_8_8_odd
-
- convert_8_8_next:
- nxtscan si,src_next_scan
- nxtscan di,dst_next_scan
-
- dec scan_count
- jnz short convert_8_8_start
- cEnd
-
- convert_8_8_odd:
- @@: mov bl,fs:[esi]
- mov bl,[ebx]
- mov es:[edi],bl
- inc esi
- inc edi
- dec ecx
- jnz short convert_8_8_odd
- jz short convert_8_8_next
-
- endif
-
-
- sEnd CodeSeg
-
- end
-
- COMMENT |
-
- Todd's old code:
-
- align 4
- convert_8_8_start:
- mov ecx,edx ;pel_count
- shr ecx,2
- jz short convert_8_8_ack
- align 4
- convert_8_8_loop:
- mov eax,fs:[esi] ; grab 4 pixels
-
- mov bl,al ; get pel
- mov al,[ebx] ; translate pel
- mov bl,ah ; get pel
- mov ah,[ebx] ; translate pel
-
- rol eax,16
-
- mov bl,al ; get pel
- mov al,[ebx] ; translate pel
- mov bl,ah ; get pel
- mov ah,[ebx] ; translate pel
-
- rol eax,16
- mov es:[edi],eax ; store four
-
- add esi,4
- add edi,4
- dec ecx
- jnz short convert_8_8_loop
-
- convert_8_8_ack:
- mov ecx,edx ;pel_count
- and ecx,3
- jnz short convert_8_8_odd
-
- convert_8_8_next:
- nxtscan si,src_next_scan
- nxtscan di,dst_next_scan
-
- dec scan_count
- jnz short convert_8_8_start
-
- My third try:
-
- convert_8_8_start:
-
- mov ecx,pel_count
- shr ecx,2
- jz short convert_8_8_ack
-
- shr ecx,1
- jc fixup_for_halfway
-
- align 4
-
- convert_8_8_loop:
-
- mov eax,fs:[esi] ; grab 4 pixels
-
- mov bl,al ; get pel
- mov dl,ah ; get pel
- mov al,[ebx] ; translate pel
- mov ah,[edx] ; translate pel
-
- rol eax,16
-
- mov bl,al ; get pel
- mov dl,ah ; get pel
- mov al,[ebx] ; translate pel
- mov ah,[edx] ; translate pel
-
- rol eax,16
-
- mov es:[edi],eax ; store four
-
- half_way:
- mov eax,fs:[esi+4] ; grab 4 pixels
-
- mov bl,al ; get pel
- mov dl,ah ; get pel
- mov al,[ebx] ; translate pel
- mov ah,[edx] ; translate pel
-
- rol eax,16
-
- mov bl,al ; get pel
- mov dl,ah ; get pel
- mov al,[ebx] ; translate pel
- mov ah,[edx] ; translate pel
-
- rol eax,16
-
- mov es:[edi+4],eax ; store four
-
- add esi,8
- add edi,8
-
- dec ecx
- jnz short convert_8_8_loop
-
- convert_8_8_ack:
- mov ecx,pel_count
- and ecx,3
- jnz short convert_8_8_odd
-
- convert_8_8_next:
- nxtscan si,src_next_scan
- nxtscan di,dst_next_scan
-
- dec scan_count
- jnz short convert_8_8_start
- cEnd
-
- fixup_for_halfway:
- sub edi,4
- sub esi,4
- jmp half_way
-
- convert_8_8_odd:
- @@: mov bl,fs:[esi]
- mov bl,[ebx]
- mov es:[edi],bl
- inc esi
- inc edi
- dec ecx
- jnz short convert_8_8_odd
- jz short convert_8_8_next
-
- -----
-
- xor esi,esi
- xor edi,edi
- xor ebx,ebx
- xor edx,edx
-
- lfs si,src_ptr
- les di,dst_ptr
- lds bx,xlat_table
-
- add esi,src_offset
- add edi,dst_offset
-
- mov eax,pel_count
- sub src_next_scan,eax
- sub dst_next_scan,eax
-
- align 4
- convert_8_8_start:
-
- mov ecx,pel_count
- shr ecx,2
- jz short convert_8_8_ack
-
- align 4
-
- convert_8_8_loop:
-
- mov eax,fs:[esi+2] ; grab 2 pixels
-
- mov bl,al ; get pel
- mov dl,ah ; get pel
- mov al,[ebx] ; translate pel
- mov ah,[edx] ; translate pel
-
- shl eax,16
-
- mov ax,fs:[esi] ; grab 2 more
-
- mov bl,al ; get pel
- mov dl,ah ; get pel
- mov al,[ebx] ; translate pel
- mov ah,[edx] ; translate pel
-
- mov es:[edi],eax ; store four
-
- add esi,4
- add edi,4
-
- dec ecx
- jnz short convert_8_8_loop
-
- convert_8_8_ack:
- mov ecx,pel_count
- and ecx,3
- jnz short convert_8_8_odd
-
- convert_8_8_next:
- nxtscan si,src_next_scan
- nxtscan di,dst_next_scan
-
- dec scan_count
- jnz short convert_8_8_start
- cEnd
-
- convert_8_8_odd:
- @@: mov bl,fs:[esi]
- mov bl,[ebx]
- mov es:[edi],bl
- inc esi
- inc edi
- dec ecx
- jnz short convert_8_8_odd
- jz short convert_8_8_next
-
-
- ENDCOMMENT |
-